﻿using System;

namespace MyLib.Web.UI {
	/// <summary>
	/// 
	/// </summary>
	public class MyInputControl : System.Web.UI.HtmlControls.HtmlInputControl {
		/// <summary>
		/// 
		/// </summary>
		public override string Name {
			get {
				string str = Attributes["name"];
				if (str == null) {
					return string.Empty;
				}
				return str;
			}
			set {
				if (string.IsNullOrEmpty(value))
					Attributes["name"] = null;
				else
					Attributes["name"] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="writer"></param>
		protected override void RenderAttributes(System.Web.UI.HtmlTextWriter writer) {
			bool flag1 = false;
			bool flag2 = false;

			string name = this.Name;
			if (!string.IsNullOrEmpty(name)) {
				writer.WriteAttribute("name", name);
				base.Attributes.Remove("name");
				flag1 = true;
			}

			string type = this.Type;
			if (!string.IsNullOrEmpty(type)) {
				writer.WriteAttribute("type", type);
				base.Attributes.Remove("type");
				flag2 = true;
			}

			if (this.ID != null) {
				writer.WriteAttribute("id", this.ClientID);
			}
			this.Attributes.Render(writer);

			if (flag1 && base.DesignMode) {
				base.Attributes.Add("name", name);
			}
			if (flag2 && base.DesignMode) {
				base.Attributes.Add("type", type);
			}
			writer.Write(" /");

		}

		/// <summary>
		/// 
		/// </summary>
		public MyInputControl()
			: this("text") {
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="type"></param>
		public MyInputControl(string type)
			: base(type) {
		}
	} // end of MyInputControl.
}
